<?xml version="1.0"?>

<!-- 
  Here is my initial attempt to get something started. Then I decided it
  would be best to let my students finish it. :-)
-->

<!--
  aml == aggregation markup language
  Basically, a namespace for any tags I may need to group elements 
  temporarily.
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:atom="http://www.w3.org/2005/Atom"
  xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" 
  xmlns:georss="http://www.georss.org/georss"
  xmlns:aml="http://markup-languages.googlecode.com/ns/aml"
  version="1.0">
  
  <!-- Note: My list of xmlns bindings is not complete here. -->
  <xsl:output method="xml" indent="yes" />
  
  <xsl:template match="/feeds" >
    <aml:aggregated>
      <xsl:for-each select="feed">
        <xsl:element name="aml:blog">
          <xsl:copy-of select="@uri"/>  
          <xsl:apply-templates select="document(@uri)" mode="document"/>
        </xsl:element>
      </xsl:for-each>
    </aml:aggregated>
  </xsl:template>
  
  <xsl:template match="rss/channel" mode="document">
    <xsl:for-each select="item">
      <xsl:sort order="descending" select="atom:updated/text()"/>
      <xsl:copy-of select="."/>  <!-- This copies the item, verbatim -->
    </xsl:for-each>
  </xsl:template>
  
</xsl:stylesheet>
